home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / FWCommon / Include / FWPriStr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-21  |  2.2 KB  |  83 lines  |  [TEXT/MPS ]

  1. #ifndef FWPRISTR_H
  2. #define FWPRISTR_H
  3. //========================================================================================
  4. //
  5. //    File:                FWPriStr.h
  6. //    Release Version:    $ 1.0d1 $
  7. //
  8. //    Creation Date:        3/25/94
  9. //
  10. //    Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  11. //
  12. //========================================================================================
  13.  
  14. #include <stddef.h>
  15.  
  16. size_t FW_PrimitiveStringLength(const char * p);
  17.     // Returns the length of string p.
  18.     
  19. int FW_PrimitiveStringEqual(const char *p1, const char *p2);
  20.     // Compares string p1 to p2. Returns 1 if equal and 0 if false.
  21.     
  22. char * FW_PrimitiveStringCopy(char *destination, char *source);
  23.     // Copies string source to string destination. Returns source.
  24.         
  25. char * FW_PrimitiveStringFindCharacter(const char *source, char c);
  26.     // Return pointer to first occurrence of c in source or NULL if not present.
  27.     
  28. char FW_PrimitiveStringToUpper(char c);
  29.     // Return character c converted to upper case.
  30.     
  31. char FW_PrimitiveStringToLower(char c);
  32.     // Return character c converted to lower case.
  33.  
  34. char FW_PrimitiveStringIsSpace(char c);
  35.     // Returns non-zero if character is space, tab, carriage return, or newline.
  36.  
  37. //========================================================================================
  38. // FWPriStr.h inlines
  39. //========================================================================================
  40.  
  41. inline char FW_PrimitiveStringToUpper(char c)
  42. {
  43. #ifdef FW_BUILD_MAC
  44.     if (c >= 'a' && c <= 'z')
  45.         return (c - 'a' + 'A');
  46.     else
  47.         return (c);
  48. #endif
  49.  
  50. // Use the standard library version to take advantage of locale information
  51. #ifdef FW_BUILD_WIN
  52.     return toupper(c);
  53. #endif
  54. }
  55.  
  56.  
  57. inline char FW_PrimitiveStringToLower(char c)
  58. {
  59. #ifdef FW_BUILD_MAC
  60.     if (c >= 'A' && c <= 'Z')
  61.         return (c + 'a' - 'A');
  62.     else
  63.         return (c);
  64. #endif
  65.  
  66. // Use the standard library version to take advantage of locale information
  67. #ifdef FW_BUILD_WIN
  68.     return tolower(c);
  69. #endif
  70. }
  71.  
  72. inline char FW_PrimitiveStringIsSpace(char c)
  73. {
  74. #ifdef FW_BUILD_MAC
  75.     return ((c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f') ? c : 0);
  76. #endif
  77.  
  78. // Use the standard library version to take advantage of locale information
  79. #ifdef FW_BUILD_WIN
  80.     return isspace(c);
  81. #endif
  82. }
  83. #endif